<template>
  <div>
    <h1>{{ obj.a }}</h1>
    <h1>{{ obj.b.c }}</h1>
    <button @click="getValue">按钮</button>
  </div>
</template>

<script lang="ts">
import { defineComponent, reactive, readonly, shallowReadonly } from "vue";

export default defineComponent({
  setup() {
    const obj = reactive({
      a: 1,
      b: {
        c: 2,
      },
    });
    const roObj = readonly(obj);
    const soObj = shallowReadonly(obj);
    const getValue = () => {
      console.log(obj.a);
      console.log(obj.b.c);
      console.log(roObj.a);
      soObj.b.c++;
    };
    return {
      obj,
      getValue,
    };
  },
});
</script>

<style scoped>
</style>